// 检查用户是否登录
exports.checkLogin = (req, res, next) => {
    if (req.session && req.session.user) {
        return next()
    }
    req.flash('error', '该页面需要登录后访问！')
    // return res.redirect(`/login`)
    return res.redirect(`/login?callback=${req.originalUrl}`)
}

// 检查是否没有登陆
exports.checkNoLogin = (req, res, next) => {
    if (req.session && req.session.user) {
        return res.redirect('/')
    }
    return next()
}


